package com.maxmlr.demo.spring.cloud.autoconfigure;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * @ClassName MaxmlrDemoAutoConfiguration
 * @Description TODO
 * @Author maxiao
 * @Date 2020/4/12 下午5:36
 * @Version V1.0
 */
@Configuration
@EnableConfigurationProperties(MaxmlrDemoProperties.class)
public class MaxmlrDemoAutoConfiguration {

    private static final Logger logger = LoggerFactory.getLogger(MaxmlrDemoAutoConfiguration.class);

    private final MaxmlrDemoProperties properties;

    public MaxmlrDemoAutoConfiguration(MaxmlrDemoProperties properties) {
        this.properties = properties;
    }

    @Bean
    public MaxmlrDemoFactory maxmlrDemoFactory() {
        System.out.println("new MaxmlrDemoFactory:" + properties.toString());
        System.out.println("name:" + properties.getName());
        System.out.println("path:" + Arrays.toString(properties.getPath()));
        return new MaxmlrDemoFactory();
    }
}
